<template>
  <div class="heritageRoad">
    <!-- header -->
    <Head />
    <Banner />
    <Nav />
    <!-- /header -->

    <div class="main">
      <div class="middle">
        <!-- 导航栏 -->
        <SideBar></SideBar>
        <!-- 导航栏 -->
        <!-- 工作室概况 -->
        <div class="block">
          <!-- 标题 -->
          <div class="title">
            <h3 @click="$router.push({ path: '/thesis' })">论文著作</h3>
          </div>
          <!-- 内容 -->
          <div class="content">
            <h3>{{ lwzzDetail.title }}</h3>
            <p>
              <span>{{ lwzzDetail.addtime | dateFormat }}</span>
              <span>作者：</span>
              <span>{{ lwzzDetail.adduser }}</span>
              <span>浏览：</span>
              <span>{{ lwzzDetail.djs }}</span>
            </p>
            <div class="detailb">
              <!-- <div style="width: 500px; margin: 0 auto">
                <object
                  class="embedbox"
                  :style="{
                    width: '100%',
                    height: '2040px',
                  }"
                  ref="pdf"
                  :data="pdfurl"
                ></object>
              </div> -->
              <p v-html="lwzzDetail.lwjs">
                {{ lwzzDetail.lwjs }}
              </p>

              <!-- <div id="canvas"></div> -->
            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- footer -->
    <Footer></Footer>
    <!-- /footer -->
  </div>
</template>

<script>
import pdf from "vue-pdf";
import Head from "@/components/Head.vue";
import Banner from "@/components/Banner.vue";
import Nav from "@/components/Nav.vue";
import Footer from "@/components/Footer.vue";
import SideBar from "@/components/SideBar.vue";
export default {
  name: "HeritageRoad",
  components: {
    Head,
    Banner,
    Nav,
    Footer,
    SideBar,
    pdf,
  },
  data() {
    return {
      lwzzDetail: {}, //传承之路详情页
      id: "", //路由id
      // ispdf: false,
      pdfurl: "",
      pdfheight: "",
    };
  },
  created() {
    // 获取路由id
    this.getId();
    this.getMenulist();
  },
  methods: {
    //首页接口
    getMenulist() {
      var query = {
        id: this.id,
        page: 1,
        limit: 10,
      };
      this.$axios
        .get("TCM/lwzz", { params: query })
        .then((res) => {
          if (res.status == 200) {
            console.log(res);
            this.lwzzDetail = res.data.data[0];
            // if (this.lwzzDetail.lwjs.indexOf("object") == 1) {
            // this.ispdf = true;
            console.log(this.lwzzDetail.lwjs);
            var oDiv = document.createElement("div");
            oDiv.innerHTML = this.lwzzDetail.lwjs;
            console.log(oDiv.childNodes, "data");
            this.pdfurl =
              oDiv.childNodes[0].data + "#scrollbars=0&toolbar=0&statusbar=0";
            console.log(this.pdfurl, "pdfurl");

            var img = new Image();
            img.src = this.pdfurl; //pdf地址
            // alert(img.width + "__" + img.height);
            this.pdfheight = img.height - 0 + 40;
            console.log(this.pdfheight, img.width, "hei");
            // } else {
            //   this.ispdf = false;
            // }
          }
        })
        .catch((err) => {
          console.log(err);
        });
    },
    // 获取路由的id
    getId() {
      this.id = this.$route.params.id;
    },
    getStr(str) {
      return str.match(/<([^\/]|\s)*?>(?:[^<])*/g);
    },
  },
};
</script>

<style lang="less" scoped>
@media screen and (max-width: 1200px) {
  .heritageRoad .main {
    margin: 0 !important;
  }
}
.embedbox embed {
  -webkit-transform: translate(30px, -50px);
  transform: translate(30px, -50px);
  width: 900px;
  height: 100%;
}
.heritageRoad {
  background: url("../assets/image/diwen.jpg") repeat-y;
  // 通知道公告
  .main {
    margin: 0 auto;
    margin: 0 25% 0;
    height: 100%;
    background-color: #ffffff;
    overflow: hidden;
    .middle {
      height: 100%;
      padding: 0 10px 10px;
      background-color: #ffffff;
      box-sizing: border-box;
      margin-top: 20px;
      display: flex;
      justify-content: space-between;
      .block {
        flex: 1;
        margin-left: 20px;
        background-color: #ffffff;
        border: 0.5px solid #ebe4d9;
        border-top: none;
        .content {
          text-align: center;
          padding: 20px 20px 10px;
          h3 {
            font-size: 24px;
            text-align: center;
            color: #2c3e50;
            margin-bottom: 20px;
          }
          span {
            font-size: 16px;
            margin-right: 10px;
          }
        }
      }
    }
  }
}
</style>
<style lang="less">
.detailb {
  text-align: left;
  padding-top: 20px;
  float: left;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 1px;
  line-height: 30px;
  // margin-top: 0;
  // width: 100%;
  margin-bottom: 60px;
  img {
    width: 100%;
    padding-top: 15px;
    display: block;
  }
  p {
    margin-top: 0;
    text-indent: 2em;
    font-size: 16px;
  }
}
</style>
